package com.leen.video.controller;

import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.video.entity.LocalStorage;
import com.leen.video.entity.QiniuConfig;
import com.leen.video.repository.QiniuConfigRepository;
import com.leen.video.service.QiniuConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * <p>
 * 七牛云配置 前端控制器
 * </p>
 *
 * @author yy
 * @since 2021-05-19
 */
@RestController
@Api(tags = "七牛云配置接口API")
@RequestMapping("/video")
public class QiniuConfigController {

    @Autowired
    private QiniuConfigService qiniuConfigService;

    @ApiOperation(value = "全查询")
    @GetMapping(value = "/qiniuConfig/findAll")
    public ResultVO<ResultVO> findAll(){
        return ResultVO.success(this.qiniuConfigService.findAll());
    }

    @ApiOperation(value = "新增数据")
    @PostMapping(value = "/qiniuConfig/add")
    public ResultVO<String> add(@RequestBody QiniuConfig qiniuConfig){
        QiniuConfig save =this.qiniuConfigService.save(qiniuConfig);
        return save!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }

    @ApiOperation(value = "修改数据")
    @PostMapping(value = "/qiniuConfig/updata")
    public ResultVO<String> updata(@RequestBody QiniuConfig qiniuConfig){
        QiniuConfig updata =this.qiniuConfigService.save(qiniuConfig);
        return updata!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }

}

